define(
			[
			 'underscore',
			 'backbone',
			 'views/business/AlarmUserListView',
			 'collections/business/AlarmUserCollection',
			 'models/business/AlarmUserGridModel',
			 'query/views/PagerView',
			 'query/views/QueryFormView',
			 'query/colllections/OptionCollection',
			 'query/models/OptionModel',
			 'query/views/SelectView',
			 'json'
        	],
        	function(_,
        			Backbone,
        			AlarmUserGridView, 
        			AlarmUserCollection,
        			AlarmUserGridModel,
        			PagerView,
        			QueryFormView,
        			OptionCollection, 
        			OptionModel, 
        			SelectView,
        			JSON) {
				var queryData = {
						fields : [{value : "alarm_user_code", text : "用户编号"}, {value : "alarm_user_name", text : "用户名称"}, {value : "state", text : "用户状态"}],
						ops : [{value : "eq", text : "等于"}, {value : "ne", text : "不等于"}, {value : "lt", text : "小于"},
						       {value : "le", text : "小于等于"}, {value : "gt", text : "大于"}, {value : "ge", text : "大于等于"},
						       {value : "bw", text : "开始于"}, {value : "bn", text : "不开始于"},
						       {value : "ew", text : "结束于"}, {value : "en", text : "不结束于"},
						       {value : "cn", text : "包含"}, {value : "nc", text : "不包含"}],
						groupOps : [{value : "and", text : "全部"}, {value : "or", text : "任一"}],
						groupOp : "and",
						rules : [
						        	{field : "alarm_user_code", op : "eq", data : ""}
						        	//{field : "alarm_user_name", op : "bw", data : ""}
						        ]
				};
				return {
					initialize : function (_el) {
						var alarmUserGridModel = new AlarmUserGridModel();
						var alarmUserGridView = {};
						alarmUserGridModel.bind('change:records', function() {
								alarmUserGridView = new AlarmUserGridView({ model : alarmUserGridModel.getRecords()});
								$('#content').html(alarmUserGridView.render().el);
								
					    		var optionCollection = new OptionCollection();
					    		_.each(queryData.groupOps, function(field) {
					    			optionCollection.add(new OptionModel(field));
					    		});
								$('#grid_'+ alarmUserGridView.domId + ' table:last').before(new QueryFormView().render().el);
								new SelectView({
				    				model : optionCollection,
				    				attributes : {
				    					name : 'groupOp'
				    				}
								}).$el.prependTo('#groupOps');
						});
						alarmUserGridModel.bind('change:pagination', function() {
							if (alarmUserGridModel.get('pagination')) {
								var pagerView = new PagerView({model : alarmUserGridModel.get('pagination')});
								pagerView.paging = function(page) {
									alarmUserGridModel.fetch({
										data :  $.param({rules : JSON.stringify({page : page})})
									});
								};
								$('#grid_'+ alarmUserGridView.domId + ' table:last').after(pagerView.render().el);
							}
						});
						alarmUserGridModel.fetch({
							data :  $.param({rules : JSON.stringify({page : 1})})
			    		});
					}
				};
});